//Cristian Moral Martos

package Ejercicio01;

import utils.ImagePGM;

/**
 * Exercise 1.2 Implement the following thresholding function:
 * 
 * imThresh (imageIn, value, imageOut) // the most typical thresholding or
 * binarization function: a pixel p will have a value of 255 in imageOut if its
 * value in imageIn is greater or equal than that of value; otherwise, p will
 * have a value of 0 /
 * 
 * The image 'cam_74_umbral100.pgm' is the result of thresholding 'cam_74.pgm'
 * at value 100.
 * 
 */
public class Ejercicio12 {

	public static void main(String[] args) {
		String path = "input\\cam_74.pgm";
		ImagePGM image = new ImagePGM(path);
		int umbral = 100;

		ImagePGM output = image.applyTreshold(umbral);
		String outputPath = "output\\cam_74_treshold100.pgm";
		output.imageToFile(outputPath);

		ImagePGM image2 = new ImagePGM("input\\cam_74_umbral100.pgm");

		System.out.println("El filtro umbral de la imagen " + path
				+ " con valor " + umbral + " devuelve la imagen " + outputPath
				+ " y " + (output.compare(image2) ? "" : " no")
				+ "se ha realizado correctamente");
	}

}
